/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "引擎数据类型.h"

#include "core/shader_built_in_functions.h"
//#include <iostream>
//#include <vector>
//#include <cmath>
//#include <algorithm>

#include "几何图形/几何平面网格.h"



//// 判断一个顶点是否为耳
//bool f_polygon_isEar(const std::vector<vec3>& vertices, const std::vector<uint32>& polygon, size_t index);
//
//// 耳切法进行三角剖分
//std::vector<uint32> f_polygon_earClipping(const std::vector<vec3>& vertices, const std::vector<uint32>& polygon);
//
//// 合并外边界和孔洞为一个无孔多边形
//std::vector<uint32_t> f_polygon_mergeHoles(const std::vector<vec3>& vertices, const std::vector<uint32_t>& outer, const std::vector<std::vector<uint32_t>>& holes);
//
//// 对带孔多边形进行三角剖分
//std::vector<uint32_t> f_polygon_triangulateWithHoles(const std::vector<vec3>& vertices, const std::vector<uint32_t>& outer, const std::vector<std::vector<uint32_t>>& holes);



inline auto f_geom_Bound = [](uint32 num, vec2* vert) -> S_Bounding2 {
	S_Bounding2 bound = {{10000000,10000000}, {-10000000,-10000000}};
	for (uint32 i = 0; i < num; ++i) {
		bound.min = min(bound.min, vert[i]);
		bound.max = max(bound.max, vert[i]);
	}
	return bound;
};



void	f_polygon_构建平面(vec2 size, uvec2 细分, DEF_3Fs& v, DEF_3Fs& n, DEF_2Fs& uv, t_面顶点索引& index);
void	f_polygon_构建方体(vec3 size, uvec3 细分, DEF_3Fs& v, DEF_3Fs& n, DEF_2Fs& uv, t_面顶点索引& index);
void	f_polygon_构建圆柱(vec2 size, uvec2 细分, DEF_3Fs& v, DEF_3Fs& n, DEF_2Fs& uv, t_面顶点索引& index);
void	f_polygon_构建锥体(vec2 size, uint32 细分, DEF_3Fs& v, DEF_3Fs& n, DEF_2Fs& uv, t_面顶点索引& index);
void	f_polygon_构建球体(uint32 经度细分, uint32 维度细分, float32 半径, DEF_3Fs& v, DEF_3Fs& n, DEF_2Fs& uv, t_面顶点索引& I);


